package live.testdemo.bazi.common.constants;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;

import lombok.AllArgsConstructor;
import lombok.Getter;

import static live.testdemo.bazi.common.constants.DiZhi.丑;
import static live.testdemo.bazi.common.constants.DiZhi.亥;
import static live.testdemo.bazi.common.constants.DiZhi.午;
import static live.testdemo.bazi.common.constants.DiZhi.卯;
import static live.testdemo.bazi.common.constants.DiZhi.子;
import static live.testdemo.bazi.common.constants.DiZhi.寅;
import static live.testdemo.bazi.common.constants.DiZhi.巳;
import static live.testdemo.bazi.common.constants.DiZhi.戌;
import static live.testdemo.bazi.common.constants.DiZhi.未;
import static live.testdemo.bazi.common.constants.DiZhi.申;
import static live.testdemo.bazi.common.constants.DiZhi.辰;
import static live.testdemo.bazi.common.constants.DiZhi.酉;

/**
 * 四季。春夏秋冬
 *
 * @author zhoujianxin
 * @date 2023/1/26 04:33.
 */
@Getter
@AllArgsConstructor
public enum SiJi {
    春(new DiZhi[]{寅, 卯}),
    夏(new DiZhi[]{巳, 午}),
    秋(new DiZhi[]{申, 酉}),
    冬(new DiZhi[]{亥, 子}),
    四季(new DiZhi[]{辰, 戌, 丑, 未}),
    ;
    private DiZhi[] diZhi;

    /**
     * 根据地支 获取季节
     * 深度定制，不会存在为null的情况
     *
     * @param diZhi
     * @return
     */
    public static SiJi getSiJi(DiZhi diZhi) {
        return Arrays.stream(SiJi.values()).filter(x -> ArrayUtils.contains(x.getDiZhi(), diZhi))
                .findFirst().get();
    }
}
